#pragma once
#include "DSCallBackBase.h"

template < class CTargetClass >
class DSTHREADTOOLS_API CDSCallbackT : public CDSCallbackBase
{
//======== Define ===========
	public:
		typedef bool (CTargetClass::*LPFUNC) (void *pID, void *pData);

//======= Data Member =======
	protected:
		CTargetClass *m_pcdsTarget;
		LPFUNC m_pTarFunc;

//======= Member function ===
	public:
		CDSCallbackT() {
			m_pcdsTarget = NULL;
		};

		~CDSCallbackT() {};

		void SetCallback(CTargetClass *pcTargetClassPtr, LPFUNC pFuncPtr) {
			m_pcdsTarget = pcTargetClassPtr;
			m_pTarFunc = pFuncPtr;
		};

		virtual bool Execute(void *pID, void *pData) const
		{
			if (m_pcdsTarget)
			{
				return (m_pcdsTarget->*m_pTarFunc)(pID, pData);
			}else{
				::printf("ERROR: The call back funciton is not set!!");
			}
			return false;
		};
};
